<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<style>
<!--
.grid .gridTbody td div{
	height: auto;
}
.pageFormContent{
	padding: 10px 0;
}
-->
</style>

<script type="text/javascript">
	var orderId = ${order.id};
	var type='${type}';
	function loadOrderItemList(){
		$('#orderItemList').loadUrl(loadOrderItemList.URL,{
			orderId:orderId,
			type:type
		},function(){
			if($('.gridTbody tr','#orderItemList').length){
				$('#orderItemValid').val('valid');
			}else{
				$('#orderItemValid').val('');
			}
			initLayout();
		});
	}
	loadOrderItemList.URL='<c:url value="/orders/listOrderItem.do"/>';
	function showOrderItem(data){
		var orderItemId = $(data).attr("rel");
		var urlpath= '<c:url value="/orders/addOrModifyOrderItem.do"/>?orderItemId='+orderItemId+'&type='+type;
		$.pdialog.open(urlpath, "addOrModifyOrderItem", "订单项详情",{width:800,height:400,mask:true});
	}
	
	$(function(){
		loadOrderItemList();
	});
</script>
<div class="pageContent">
	<form method="post" action="<c:url value="/orders/saveOrder.do" />" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
		<div class="pageFormContent"  layoutH="60">
			<p>
				<label>订单号：</label>
				<input name="orderId" type="hidden" value="${order.id}" id="orderId">
				<input name="order.orderNo" type="text" size="30" value="${order.orderNo}" readonly="readonly"/>
				<input id="orderItemValid" class="required" type="hidden" size="30" value="" title="请至少添加一个订单项"/>
			</p>
			<div style="clear: both;height:0px;"></div>
			<div class="panelBar">
				<ul class="toolBar">
				<c:if test="${type=='add'}">
					<li><a class="add"  href="<c:url value="/orders/addOrModifyOrderItem.do?orderId=${order.id}"/>" target="navTab"  rel="addOrders" external="true"><span>添加订单项</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="<c:url value="/orders/addOrModifyOrderItem.do"/>?orderItemId={orderItemId}" target="dialog" mask="true" rel="addOrModifyOrderItem" width="800" height="400" resizable="false" drawable="false" maxable="false" ><span>修改订单项</span></a></li>
					<li class="line">line</li>
					<li><a class="delete" href="<c:url value="/orders/deleteOrderItem.do"/>?orderItemId={orderItemId}" target="ajaxTodo" title="确定要删除吗?" callback="loadOrderItemList"><span>删除订单项</span></a></li>
				</c:if>
				</ul>
			</div>
			<div id="orderItemList">
			
			</div>
		</div>
		<div class="formBar">
			<ul>
				<c:if test="${type=='add'}">
								<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				</c:if>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>